package main.java.fases;

import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;


public class Turno {

	/**
	 * @uml.property  name="faseEventos"
	 * @uml.associationEnd  
	 */
	private FaseEvento faseEventos;
	
	private Vector<Jugador> jugadores;
	
	
	public Turno(Vector<Jugador> jugadores){
		this.jugadores = jugadores;
		crearfases(jugadores);
	}
		
	public void crearfases(Vector<Jugador> jugadores){
		/*
		FaseBarco fb = new FaseBarco();
		if(fb.laFaseHaTerminado()){
			FaseEvento fe = new FaseEvento();
			if(fb.laFaseHaTerminado()){
				FaseCampamento fc = new FaseCampamento();
				if(fc.laFaseHaTerminado()){
					FaseAccion fa = new FaseAccion(jugadores);
					if(fa.laFaseHaTerminado()){
						FaseAlimentacion fal = new FaseAlimentacion();
						if(fal.laFaseHaTerminado()){
							FaseHoguera fh = new FaseHoguera();
								if(fh.laFaseHaTerminado()){
									FaseDecrepitud fd = new FaseDecrepitud();
									if(fd.laFaseHaTerminado()){
										cambiarJugadorInicial();
									}
								}
							}
						}
					}
				}
			}
		}
		*/
	}
	
	public void cambiarJugadorInicial(){
		Vector<Jugador> nuevoOrden = new Vector<Jugador>();
		if(jugadores.size() != 1){
			jugadores.get(0).getPersonaje().setEsJugadorInicial(false);
			jugadores.get(1).getPersonaje().setEsJugadorInicial(true);
			for(int i=1; i<jugadores.size(); i++){
				nuevoOrden.add(jugadores.get(i));
			}
			nuevoOrden.add(jugadores.get(0));
		}
	}
	
	
	
	

	/**
	 * Getter of the property <tt>faseEventos</tt>
	 * @return  Returns the faseEventos.
	 * @uml.property  name="faseEventos"
	 */
	public FaseEvento getFaseEventos() {
		return faseEventos;
	}

	/**
	 * Setter of the property <tt>faseEventos</tt>
	 * @param faseEventos  The faseEventos to set.
	 * @uml.property  name="faseEventos"
	 */
	public void setFaseEventos(FaseEvento faseEventos) {
		this.faseEventos = faseEventos;
	}

	/**
	 * @uml.property  name="faseEventos1"
	 * @uml.associationEnd  multiplicity="(1 -1)" aggregation="composite" inverse="turnos1:Diagrama2.FaseEvento"
	 */
	private Collection faseEventos1;

	/**
	 * Getter of the property <tt>faseEventos1</tt>
	 * @return  Returns the faseEventos1.
	 * @uml.property  name="faseEventos1"
	 */
	public Collection getFaseEventos1() {
		return faseEventos1;
	}

	/**
	 * Returns an iterator over the elements in this collection. 
	 * @return  an <tt>Iterator</tt> over the elements in this collection
	 * @see java.util.Collection#iterator()
	 * @uml.property  name="faseEventos1"
	 */
	public Iterator faseEventos1Iterator() {
		return faseEventos1.iterator();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains no elements.
	 * @return  <tt>true</tt> if this collection contains no elements
	 * @see java.util.Collection#isEmpty()
	 * @uml.property  name="faseEventos1"
	 */
	public boolean isFaseEventos1Empty() {
		return faseEventos1.isEmpty();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains the specified element. 
	 * @param element  whose presence in this collection is to be tested.
	 * @see java.util.Collection#contains(Object)
	 * @uml.property  name="faseEventos1"
	 */
	public boolean containsFaseEventos1(FaseEvento faseEventos) {
		return faseEventos1.contains(faseEventos);
	}

	/**
	 * Returns <tt>true</tt> if this collection contains all of the elements in the specified collection.
	 * @param elements  collection to be checked for containment in this collection.
	 * @see java.util.Collection#containsAll(Collection)
	 * @uml.property  name="faseEventos1"
	 */
	public boolean containsAllFaseEventos1(Collection faseEventos1) {
		return this.faseEventos1.containsAll(faseEventos1);
	}

	/**
	 * Returns the number of elements in this collection.
	 * @return  the number of elements in this collection
	 * @see java.util.Collection#size()
	 * @uml.property  name="faseEventos1"
	 */
	public int faseEventos1Size() {
		return faseEventos1.size();
	}

	/**
	 * Returns all elements of this collection in an array.
	 * @return  an array containing all of the elements in this collection
	 * @see java.util.Collection#toArray()
	 * @uml.property  name="faseEventos1"
	 */
	public FaseEvento[] faseEventos1ToArray() {
		return (FaseEvento[]) faseEventos1.toArray(new FaseEvento[faseEventos1
				.size()]);
	}

	/**
	 * Returns an array containing all of the elements in this collection;  the runtime type of the returned array is that of the specified array.
	 * @param a  the array into which the elements of this collection are to be stored.
	 * @return  an array containing all of the elements in this collection
	 * @see java.util.Collection#toArray(Object[])
	 * @uml.property  name="faseEventos1"
	 */
	public FaseEvento[] faseEventos1ToArray(FaseEvento[] faseEventos1) {
		return (FaseEvento[]) this.faseEventos1.toArray(faseEventos1);
	}

	/**
	 * Ensures that this collection contains the specified element (optional operation). 
	 * @param element  whose presence in this collection is to be ensured.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="faseEventos1"
	 */
	public boolean addFaseEventos1(FaseEvento faseEventos) {
		return faseEventos1.add(faseEventos);
	}

	/**
	 * Setter of the property <tt>faseEventos1</tt>
	 * @param faseEventos1  the faseEventos1 to set.
	 * @uml.property  name="faseEventos1"
	 */
	public void setFaseEventos1(Collection faseEventos1) {
		this.faseEventos1 = faseEventos1;
	}

	/**
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
	 * @param element  to be removed from this collection, if present.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="faseEventos1"
	 */
	public boolean removeFaseEventos1(FaseEvento faseEventos) {
		return faseEventos1.remove(faseEventos);
	}

	/**
	 * Removes all of the elements from this collection (optional operation).
	 * @see java.util.Collection#clear()
	 * @uml.property  name="faseEventos1"
	 */
	public void clearFaseEventos1() {
		faseEventos1.clear();
	}

	/**
	 * @uml.property  name="faseEventos2"
	 * @uml.associationEnd  multiplicity="(1 -1)" aggregation="composite" inverse="turnos3:Diagrama2.FaseEvento"
	 */
	private Collection faseEventos2;

	/**
	 * Getter of the property <tt>faseEventos2</tt>
	 * @return  Returns the faseEventos2.
	 * @uml.property  name="faseEventos2"
	 */
	public Collection getFaseEventos2() {
		return faseEventos2;
	}

	/**
	 * Returns an iterator over the elements in this collection. 
	 * @return  an <tt>Iterator</tt> over the elements in this collection
	 * @see java.util.Collection#iterator()
	 * @uml.property  name="faseEventos2"
	 */
	public Iterator faseEventos2Iterator() {
		return faseEventos2.iterator();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains no elements.
	 * @return  <tt>true</tt> if this collection contains no elements
	 * @see java.util.Collection#isEmpty()
	 * @uml.property  name="faseEventos2"
	 */
	public boolean isFaseEventos2Empty() {
		return faseEventos2.isEmpty();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains the specified element. 
	 * @param element  whose presence in this collection is to be tested.
	 * @see java.util.Collection#contains(Object)
	 * @uml.property  name="faseEventos2"
	 */
	public boolean containsFaseEventos2(FaseEvento faseEventos) {
		return faseEventos2.contains(faseEventos);
	}

	/**
	 * Returns <tt>true</tt> if this collection contains all of the elements in the specified collection.
	 * @param elements  collection to be checked for containment in this collection.
	 * @see java.util.Collection#containsAll(Collection)
	 * @uml.property  name="faseEventos2"
	 */
	public boolean containsAllFaseEventos2(Collection faseEventos2) {
		return this.faseEventos2.containsAll(faseEventos2);
	}

	/**
	 * Returns the number of elements in this collection.
	 * @return  the number of elements in this collection
	 * @see java.util.Collection#size()
	 * @uml.property  name="faseEventos2"
	 */
	public int faseEventos2Size() {
		return faseEventos2.size();
	}

	/**
	 * Returns all elements of this collection in an array.
	 * @return  an array containing all of the elements in this collection
	 * @see java.util.Collection#toArray()
	 * @uml.property  name="faseEventos2"
	 */
	public FaseEvento[] faseEventos2ToArray() {
		return (FaseEvento[]) faseEventos2.toArray(new FaseEvento[faseEventos2
				.size()]);
	}

	/**
	 * Returns an array containing all of the elements in this collection;  the runtime type of the returned array is that of the specified array.
	 * @param a  the array into which the elements of this collection are to be stored.
	 * @return  an array containing all of the elements in this collection
	 * @see java.util.Collection#toArray(Object[])
	 * @uml.property  name="faseEventos2"
	 */
	public FaseEvento[] faseEventos2ToArray(FaseEvento[] faseEventos2) {
		return (FaseEvento[]) this.faseEventos2.toArray(faseEventos2);
	}

	/**
	 * Ensures that this collection contains the specified element (optional operation). 
	 * @param element  whose presence in this collection is to be ensured.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="faseEventos2"
	 */
	public boolean addFaseEventos2(FaseEvento faseEventos) {
		return faseEventos2.add(faseEventos);
	}

	/**
	 * Setter of the property <tt>faseEventos2</tt>
	 * @param faseEventos2  the faseEventos2 to set.
	 * @uml.property  name="faseEventos2"
	 */
	public void setFaseEventos2(Collection faseEventos2) {
		this.faseEventos2 = faseEventos2;
	}

	/**
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
	 * @param element  to be removed from this collection, if present.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="faseEventos2"
	 */
	public boolean removeFaseEventos2(FaseEvento faseEventos) {
		return faseEventos2.remove(faseEventos);
	}

	/**
	 * Removes all of the elements from this collection (optional operation).
	 * @see java.util.Collection#clear()
	 * @uml.property  name="faseEventos2"
	 */
	public void clearFaseEventos2() {
		faseEventos2.clear();
	}

	/**
	 * @uml.property  name="partida"
	 * @uml.associationEnd  
	 */
	private Partida partida;

	/**
	 * Getter of the property <tt>partida</tt>
	 * @return  Returns the partida.
	 * @uml.property  name="partida"
	 */
	public Partida getPartida() {
		return partida;
	}

	/**
	 * Setter of the property <tt>partida</tt>
	 * @param partida  The partida to set.
	 * @uml.property  name="partida"
	 */
	public void setPartida(Partida partida) {
		this.partida = partida;
	}

	/**
	 * @uml.property  name="fase"
	 * @uml.associationEnd  multiplicity="(0 -1)" aggregation="shared" inverse="turno:Diagrama2.Fase"
	 */
	private Collection fase;

	/** 
	 * Getter of the property <tt>fase</tt>
	 * @return  Returns the fase.
	 * @uml.property  name="fase"
	 */
	public Collection getFase() {
		return fase;
	}

	/**
	 * Returns an iterator over the elements in this collection. 
	 * @return  an <tt>Iterator</tt> over the elements in this collection
	 * @see java.util.Collection#iterator()
	 * @uml.property  name="fase"
	 */
	public Iterator faseIterator() {
		return fase.iterator();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains no elements.
	 * @return  <tt>true</tt> if this collection contains no elements
	 * @see java.util.Collection#isEmpty()
	 * @uml.property  name="fase"
	 */
	public boolean isFaseEmpty() {
		return fase.isEmpty();
	}

	/**
	 * Returns <tt>true</tt> if this collection contains the specified element. 
	 * @param element  whose presence in this collection is to be tested.
	 * @see java.util.Collection#contains(Object)
	 * @uml.property  name="fase"
	 */
	public boolean containsFase(Fase fase) {
		return this.fase.contains(fase);
	}

	/**
	 * Returns <tt>true</tt> if this collection contains all of the elements in the specified collection.
	 * @param elements  collection to be checked for containment in this collection.
	 * @see java.util.Collection#containsAll(Collection)
	 * @uml.property  name="fase"
	 */
	public boolean containsAllFase(Collection fase) {
		return this.fase.containsAll(fase);
	}

	/**
	 * Returns the number of elements in this collection.
	 * @return  the number of elements in this collection
	 * @see java.util.Collection#size()
	 * @uml.property  name="fase"
	 */
	public int faseSize() {
		return fase.size();
	}

	/**
	 * Returns all elements of this collection in an array.
	 * @return  an array containing all of the elements in this collection
	 * @see java.util.Collection#toArray()
	 * @uml.property  name="fase"
	 */
	public Fase[] faseToArray() {
		return (Fase[]) fase.toArray(new Fase[fase.size()]);
	}

	/**
	 * Returns an array containing all of the elements in this collection;  the runtime type of the returned array is that of the specified array.
	 * @param a  the array into which the elements of this collection are to be stored.
	 * @return  an array containing all of the elements in this collection
	 * @see java.util.Collection#toArray(Object[])
	 * @uml.property  name="fase"
	 */
	public Fase[] faseToArray(Fase[] fase) {
		return (Fase[]) this.fase.toArray(fase);
	}

	/**
	 * Ensures that this collection contains the specified element (optional operation). 
	 * @param element  whose presence in this collection is to be ensured.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="fase"
	 */
	public boolean addFase(Fase fase) {
		return this.fase.add(fase);
	}

	/** 
	 * Setter of the property <tt>fase</tt>
	 * @param fase  The fase to set.
	 * @uml.property  name="fase"
	 */
	public void setFase(Collection fase) {
		this.fase = fase;
	}

	/**
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
	 * @param element  to be removed from this collection, if present.
	 * @see java.util.Collection#add(Object)
	 * @uml.property  name="fase"
	 */
	public boolean removeFase(Fase fase) {
		return this.fase.remove(fase);
	}

	/**
	 * Removes all of the elements from this collection (optional operation).
	 * @see java.util.Collection#clear()
	 * @uml.property  name="fase"
	 */
	public void clearFase() {
		this.fase.clear();
	}

	/**
	 * @uml.property  name="fase1"
	 * @uml.associationEnd  multiplicity="(0 -1)" aggregation="shared" inverse="turno1:Diagrama2.Fase"
	 */
	private Collection<Fase> fase1;

	/**
	 * Getter of the property <tt>fase1</tt>
	 * @return  Returns the fase1.
	 * @uml.property  name="fase1"
	 */
	public Collection<Fase> getFase1() {
		return fase1;
	}

	/**
	 * Setter of the property <tt>fase1</tt>
	 * @param fase1  The fase1 to set.
	 * @uml.property  name="fase1"
	 */
	public void setFase1(Collection<Fase> fase1) {
		this.fase1 = fase1;
	}

	/**
	 * @uml.property   name="partida1"
	 * @uml.associationEnd   aggregation="shared" inverse="turno2:tablero.Partida"
	 */
	private Partida partida1;

	/**
	 * Getter of the property <tt>partida1</tt>
	 * @return  Returns the partida1.
	 * @uml.property  name="partida1"
	 */
	public Partida getPartida1() {
		return partida1;
	}

	/**
	 * Setter of the property <tt>partida1</tt>
	 * @param partida1  The partida1 to set.
	 * @uml.property  name="partida1"
	 */
	public void setPartida1(Partida partida1) {
		this.partida1 = partida1;
	}

	/**
	 * @uml.property  name="fase2"
	 * @uml.associationEnd  inverse="turno1:fases.Fase"
	 */
	private Fase fase2;

	/**
	 * Getter of the property <tt>fase2</tt>
	 * @return  Returns the fase2.
	 * @uml.property  name="fase2"
	 */
	public Fase getFase2() {
		return fase2;
	}

	/**
	 * Setter of the property <tt>fase2</tt>
	 * @param fase2  The fase2 to set.
	 * @uml.property  name="fase2"
	 */
	public void setFase2(Fase fase2) {
		this.fase2 = fase2;
	}

}
